﻿#ifndef INHERENTLNK_H
#define INHERENTLNK_H

#include <QPushButton>
#include <QObject>

class InherentLNK : public QPushButton
{
    Q_OBJECT
public:
    InherentLNK(const QString & svg_name, const QString &lnk_name, QWidget *parent = nullptr, bool move_able = false);
    ~InherentLNK();

    inline void change_icon(const QString &svg_name) {setIcon(QIcon(svg_name));}
    void set_size(int wd, int ht);
    inline void set_have_rubbish(bool flag) {have_rubbish = flag;}

private:
    QString name;
    bool moveable;
    bool this_is_clicked = true;
    double press_x;
    double press_y;
    int old_x;
    int old_y;
    bool have_rubbish;

    // 鼠标拖入事件
    void dragEnterEvent(QDragEnterEvent *);
    void dropEvent(QDropEvent *);
    void dragLeaveEvent(QDragLeaveEvent *);

    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);
    void mouseMoveEvent(QMouseEvent *);
    void enterEvent(QEnterEvent *);
    void leaveEvent(QEvent *);

signals:
    void left_clicked();
    void right_clicked();
    void drag_out();
    void not_drag_out();
};

#endif // INHERENTLNK_H
